/**
 * Copyright(c) 2025 hbswxx.com, All Rights Reserved. Author: kouqiang Create date: 2025/5/30
 */
package cn.sw.syncdata.controller;

import cn.sw.syncdata.job.CreateEMLogJob;
import cn.sw.syncdata.job.CreateHardDiskInfoJob;
import cn.sw.syncdata.job.CreateHeaderJob;
import cn.sw.syncdata.job.CreatePortJob;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * description:
 *
 * @author kouqiang
 * @date 2025/5/30 13:45
 */
@RestController
@RequestMapping("/create-manager")

@Tag(name = "创建测试任务管理")
public class CreateJobManager {

    @Resource
    private CreateHeaderJob createHeaderJob;
    @Resource
    private CreatePortJob createPortJob;

    @Resource
    private CreateEMLogJob createEMLogJob;

    @Resource
    private CreateHardDiskInfoJob createHardDiskInfoJob;

    @GetMapping("/test")
    public String test() {
        return "OK";
    }

    @PostMapping("/create-header")

    @Parameters({
            @Parameter(name = "startId", description = "起始ID", required = true),
            @Parameter(name = "sdate", description = "开始时间", required = true),
            @Parameter(name = "edate", description = "结束时间", required = true),
            @Parameter(name = "total", description = "总数量", required = true)
    })
    public String createHeader(@RequestParam int startId,
                               @RequestParam String sdate,
                               @RequestParam String edate,
                               @RequestParam int total) {
        createHeaderJob.createHeaderJob(startId, sdate, edate, total);
        return "start";
    }

    @Parameters({
            @Parameter(name = "sdate", description = "开始时间", required = true),
            @Parameter(name = "edate", description = "结束时间", required = true),
            @Parameter(name = "total", description = "总数量", required = true)
    })
    @PostMapping("/create-port")
    public String createPort(@RequestParam String sdate,
                             @RequestParam String edate,
                             @RequestParam int total) {
        createPortJob.createPortJob(sdate, edate, total);
        return "ok";
    }

    @Parameters({
            @Parameter(name = "sdate", description = "开始时间", required = true),
            @Parameter(name = "edate", description = "结束时间", required = true),
            @Parameter(name = "total", description = "总数量", required = true)
    })
    @PostMapping("/create-emlog")
    public String createEMLog(@RequestParam String sdate,
                              @RequestParam String edate,
                              @RequestParam int total) {
        createEMLogJob.createEmlJob(sdate, edate, total);
        return "ok";
    }
    @Parameters({
            @Parameter(name = "sdate", description = "开始时间", required = true),
            @Parameter(name = "edate", description = "结束时间", required = true),
            @Parameter(name = "total", description = "总数量", required = true)
    })
    @Operation(summary = "创建硬盘信息")
    @PostMapping("/create-hardinfo")
    public String createHardInfo(@RequestParam String sdate,
                              @RequestParam String edate,
                              @RequestParam int total) {
        createHardDiskInfoJob.createHardDiskInfoJob(sdate, edate, total);
        return "ok";
    }
}
